package com.mb.app.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.mb.app.domain.TbColorCfg;
import com.mb.app.dao.TbColorCfgMapper;
import com.mb.app.service.ITbColorCfgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 颜色属性配置  服务实现类
 * </p>
 *
 * @author liliping
 * @since 2019-04-01
 */
@Service
@Slf4j
public class TbColorCfgServiceImpl extends ServiceImpl<TbColorCfgMapper, TbColorCfg> implements ITbColorCfgService {


    @Override
    public List<TbColorCfg> queryList(Map<String, Object> map) {
        List<TbColorCfg> list = this.baseMapper.lst(map);
        return list;
    }

    @Override
    public int count(Map<String, Object> map) {
        return this.baseMapper.countt(map);
    }

    @Override
    public int save(TbColorCfg TbColorCfg) {
        TbColorCfg.setCreateTime(new Date());
        return this.baseMapper.insert(TbColorCfg);
    }

    @Override
    public int update(TbColorCfg TbColorCfg) {
        try {
            TbColorCfg TbColorCfg1 = new TbColorCfg();
            TbColorCfg1.setColorId(TbColorCfg.getColorId());
            TbColorCfg1.setDataStatus(1);
            TbColorCfg TbColorCfgDO = this.baseMapper.selectOne(TbColorCfg1);
            if(TbColorCfgDO != null){
                TbColorCfg.setUpdateTime(new Date());
                this.baseMapper.updateById(TbColorCfg);
            }
        } catch (Exception e) {
            log.error("update Exception",e);
        }
        return 0;
    }


    @Override
    public int remove(Long classId,Long delUserId) {
//        return this.baseMapper.deleteById(appId);
        TbColorCfg TbColorCfg = new TbColorCfg();
        TbColorCfg.setColorId(classId);
        TbColorCfg.setDeleteTime(new Date());
        TbColorCfg.setDataStatus(0);
        TbColorCfg.setDeleteUserId(delUserId);
        return this.baseMapper.updateById(TbColorCfg);
    }

    @Override
    public TbColorCfg getDtl(Long bannerId) {
        TbColorCfg TbColorCfg = this.baseMapper.selectById(bannerId);
        return TbColorCfg;
    }

    @Override
    public boolean colorCfgsNameExit(Map<String, Object> params) {
        boolean exit;
        exit = this.baseMapper.selectByColorCfgInfo(params).size() > 0;
        return exit;
    }

	
}
